home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / exec / addmemlist.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  99 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: addmemlist.c,v 1.6 1996/10/24 15:50:41 aros Exp $
  4.     $Log: addmemlist.c,v $
  5.     Revision 1.6  1996/10/24 15:50:41  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.5  1996/10/19 17:07:23  aros
  9.     Include <aros/machine.h> instead of machine.h
  10.  
  11.     Revision 1.4  1996/08/13 13:55:56  digulla
  12.     Replaced AROS_LA by AROS_LHA
  13.     Replaced some AROS_LH*I by AROS_LH*
  14.     Sorted and added includes
  15.  
  16.     Revision 1.3  1996/08/01 17:41:02  digulla
  17.     Added standard header for all files
  18.  
  19.     Desc:
  20.     Lang:
  21. */
  22. #include <exec/execbase.h>
  23. #include <aros/machine.h>
  24. #include "memory.h"
  25. #include <aros/libcall.h>
  26.  
  27. /*****************************************************************************
  28.  
  29.     NAME */
  30.     #include <exec/memory.h>
  31.     #include <clib/exec_protos.h>
  32.  
  33. AROS_LH5(void, AddMemList,
  34.  
  35. /*  SYNOPSIS */
  36.     AROS_LHA(ULONG,  size,       D0),
  37.     AROS_LHA(ULONG,  attributes, D1),
  38.     AROS_LHA(LONG,   pri,        D2),
  39.     AROS_LHA(APTR,   base,       A0),
  40.     AROS_LHA(STRPTR, name,       A1),
  41.  
  42. /*  LOCATION */
  43.     struct ExecBase *, SysBase, 103, Exec)
  44.  
  45. /*  FUNCTION
  46.     Add a new block of memory to the system memory lists.
  47.  
  48.     INPUTS
  49.     size       - Size of the block
  50.     attributes - The attributes the memory will have
  51.     pri       - Priority in the list of MemHeaders
  52.     base       - Base address
  53.     name       - A name associated with the memory
  54.  
  55.     RESULT
  56.  
  57.     NOTES
  58.     No argument checking done.
  59.  
  60.     EXAMPLE
  61.  
  62.     BUGS
  63.  
  64.     SEE ALSO
  65.  
  66.     INTERNALS
  67.  
  68.     HISTORY
  69.     8-10-95    created by m. fleischer
  70.        16-10-95    increased portability
  71.  
  72. ******************************************************************************/
  73. {
  74.     AROS_LIBFUNC_INIT
  75.  
  76.     struct MemHeader *mh;
  77.  
  78.     /* Do I have to look here if it matches some other MemHeader? */
  79.     mh=(struct MemHeader *)base;
  80.     mh->mh_Node.ln_Type=NT_MEMORY;
  81.     mh->mh_Node.ln_Pri=pri;
  82.     mh->mh_Node.ln_Name=name;
  83.     mh->mh_Attributes=attributes;
  84.     mh->mh_First=(struct MemChunk *)((UBYTE *)mh+MEMHEADER_TOTAL);
  85.     mh->mh_First->mc_Next=NULL;
  86.     mh->mh_First->mc_Bytes=size-MEMHEADER_TOTAL;
  87.     mh->mh_Lower=mh->mh_First;
  88.     mh->mh_Upper=(APTR)((UBYTE *)base+size);
  89.     mh->mh_Free=mh->mh_First->mc_Bytes;
  90.  
  91.     /* Protect the memory list. */
  92.     Forbid();
  93.     /* Add MemHeader */
  94.     Enqueue(&SysBase->MemList,&mh->mh_Node);
  95.     Permit();
  96.     AROS_LIBFUNC_EXIT
  97. } /* AddMemList */
  98.  
  99.